package com.util;

import com.javabean.Role;
import mapper.RoleMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RoleMapperTest {
    SqlSessionFactory sqlSessionFactory;
    SqlSession sqlSession;
    RoleMapper mapper;

    @Before
    public void before() {
        sqlSessionFactory = MyBatisUtil.getSqlSessionFactory();
        sqlSession = sqlSessionFactory.openSession(true);
        mapper = sqlSession.getMapper(RoleMapper.class);
    }

    @After
    public void after() {
        sqlSession.close();
    }

    @Test
    public void selectAll(){
        for (Role role : mapper.selectAll()) {
            System.out.println(role);
        }
    }
    @Test
    public void deleteByRid(){
        mapper.deleteByRid(3);
    }
    @Test
    public void insertRole(){
        Role r=new Role(0,"ld","xjbld");
        mapper.insertRole(r);
    }

    @Test
    public void update(){
        mapper.updateNameByRid(4,"dl0.88A");
    }

    @Test
    public void selectR_P(){
        for (Role role : mapper.selectR_P()) {
            System.out.println(role);
        }
    }



}
